﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cesave.Domain.PermisosModule.Entities;
using Cesave.Infrastructure.Data.Core;
using Cesave.Domain.PermisosModule.Contracts.DistritosPersonal;
using Cesave.Infrastructure.Data.PermisosModule.Context;
using Cesave.Infrastructure.CrossCutting.Logging;
using Cesave.Domain.Core.Specification;

namespace Cesave.Infrastructure.Data.PermisosModule.Repositories
{
	/// <summary>
	/// 
	/// </summary>
	public class DistritoPersonalRepository
		: GenericRepositoryEx<DistritoPersonal>, IDistritoPersonalRepository
	{
		#region Constructor

		/// <summary>
		/// 
		/// </summary>
		/// <param name="context"></param>
		/// <param name="traceManager"></param>
		public DistritoPersonalRepository(IPermisosModuleContext context, ITraceManager traceManager)
			: base(context, traceManager)
		{
		}

		#endregion

		#region IDistritoPersonalRepository Members

		/// <summary>
		/// 
		/// </summary>
		/// <param name="distritoPersonalByDistritoSpecification"></param>
		/// <param name="distritoPersonalByCicloSpecification"></param>
		/// <returns></returns>
		public DistritoPersonal FindDistritoPersonalByDistritoAndCicloSpecification(DistritoPersonalByDistritoSpecification distritoPersonalByDistritoSpecification, DistritoPersonalByCicloSpecification distritoPersonalByCicloSpecification)
		{
			if (distritoPersonalByCicloSpecification == null)
				throw new ArgumentNullException("distritoPersonalByCicloSpecification");
			if (distritoPersonalByDistritoSpecification == null)
				throw new ArgumentNullException("distritoPersonalByDistritoSpecification");
			Specification<DistritoPersonal> distritoPersonalSpecification = new TrueSpecification<DistritoPersonal>();
			distritoPersonalSpecification &= distritoPersonalByCicloSpecification;
			distritoPersonalSpecification &= distritoPersonalByDistritoSpecification;
			return GetBySpec(distritoPersonalSpecification).FirstOrDefault();
		}

		#endregion
	}
}
